﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="LedgerDetails.aspx.cs" Inherits="Main_Reports_Accounts_LedgerDetails"
    Culture="en-GB" %>
<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<%@ Register Assembly="CalendarExtenderPlus" Namespace="AjaxControlToolkitPlus" TagPrefix="advancedCalender" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>General Ledger Details</title>
    <link href="../../../Styles/accounts.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function ValidationBlank() {
            if (document.getElementById("ddlLedger").value == "0") {
                alert('Specify Ledger for Details!');
                document.getElementById("ddlLedger").focus();
                return false;
            }
            else if (document.getElementById("txtFromDate").value == '') {
                alert('Specify From date!');
                document.getElementById("txtFromDate").focus();
                return false;
            }
            else if (document.getElementById("txtToDate").value == '') {
                alert('Specify To Date!');
                document.getElementById("txtToDate").focus();
                return false;
            }
            else {
                var strFromDate = document.getElementById("txtFromDate").value;
                var strToDate = document.getElementById("txtToDate").value;
                var dtFrom = parseInt(strFromDate.substring(0, 2), 10);
                var monFrom = parseInt(strFromDate.substring(3, 5), 10);
                var yrFrom = parseInt(strFromDate.substring(6, 10), 10);
                var dtTo = parseInt(strToDate.substring(0, 2), 10);
                var monTo = parseInt(strToDate.substring(3, 5), 10);
                var yrTo = parseInt(strToDate.substring(6, 10), 10);
                var dateFrom = new Date(yrFrom, monFrom, dtFrom);
                var dateTo = new Date(yrTo, monTo, dtTo);
                if (dateTo < dateFrom) {
                    alert("To date cannot be greater than from date");
                    document.getElementById("txtToDate").focus();
                    return false;
                }
                else {
                    return true;
                }
            }            
        }       
        function EnabledTabKey(id, e) {
            var keycode;
            if (window.event) {
                keycode = window.event.keyCode;
            }
            else if (e) {
                keycode = e.which;
            }
            else {
                return true;
            }

            if (keycode == 9) {
                // if is the tab key                
                return true;
            }
            else {
                return false;
            }
        }
        
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div style="width: 97%">
        <acc:heading ID="pagehead" runat="server" HeadingText="Ledgers Detail" />
    </div>
    <div style="width: 70%; margin-left: 15%; margin-right: 15%; text-align: center;">
        <asp:Label ID="lblMsg" runat="server"></asp:Label>
    </div>
    <div style="width: 100%; margin-top:7px;">
        <table width="97%" style="border:solid 1px #818181;">
            <tr>
                <td style="width: 25%; padding-top:7px; padding-left:3px;" valign="top">
                    <asp:DropDownList ID="ddlLedger" runat="server" CssClass="dropdown">
                    </asp:DropDownList>
                </td>
                <td style="width: 25%; padding-top:7px;" valign="top">
                    <asp:TextBox ID="txtFromDate" runat="server" CssClass="input" Width="100px" onkeydown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    <asp:ImageButton ID="imgFromDate" runat="server" ImageUrl="~/Images/calendar.gif" />
                    <advancedCalender:CalendarExtenderPlus ID="calFromDate" runat="server" PopupButtonID="imgFromDate"
                        Format="dd/MM/yyyy" TargetControlID="txtFromDate">
                    </advancedCalender:CalendarExtenderPlus>
                </td>
                <td style="width: 25%; padding-top:7px;" valign="top">
                    <asp:TextBox ID="txtToDate" runat="server" CssClass="input" Width="100px" onkeydown="return EnabledTabKey(this.id, event);"></asp:TextBox>
                    <asp:ImageButton ID="imgToDate" runat="server" ImageUrl="~/Images/calendar.gif" />
                    <advancedCalender:CalendarExtenderPlus ID="calToDate" runat="server" PopupButtonID="imgToDate"
                        Format="dd/MM/yyyy" TargetControlID="txtToDate">
                    </advancedCalender:CalendarExtenderPlus>
                </td>
                <td style="width: 25%; padding-top:7px;" valign="top">
                    <asp:Button ID="btnShow" runat="server" Text="Show" CssClass="button" OnClick="btnShow_Click" OnClientClick="return ValidationBlank();" />
                    <asp:LinkButton ID="btnExprotPDF" runat="server" Text="Export PDF" OnClick="btnPDF_Click"></asp:LinkButton>
                </td>
            </tr>
            <tr>
                <td colspan="4" style="width: 100%; padding-top:2px;" valign="top">
                    <asp:Label ID="lblHeading" runat="server" Font-Bold="true"></asp:Label>
                </td>
            </tr>
            <tr>
                <td colspan="4" style="width: 100%; padding-top:7px;" valign="top">
                    <asp:GridView ID="grdDisplay" DataKeyNames="TransactionID" AutoGenerateColumns="false"
                        CssClass="gridview" Width="100%" OnRowDataBound="grdDisplay_RowDataBound" ShowFooter="true"
                        runat="server">
                        <Columns>
                            <asp:BoundField DataField="TransactionDate" HeaderText="Date" DataFormatString="{0:dd-MMM-yyyy}" ItemStyle-HorizontalAlign="Justify" />
                            <asp:BoundField DataField="Particulars" HeaderText="Particulars" />
                            <asp:BoundField DataField="Name" HeaderText="Tran Type" />
                            <asp:BoundField DataField="TransactionNumber" HeaderText="Tran. No." />
                            <asp:TemplateField HeaderText="Debit" ItemStyle-HorizontalAlign="Right">
                                <ItemTemplate>
                                    <asp:Label ID="lblDebit" runat="server" Text='<%# Eval("Debit")%>'></asp:Label>
                                    <asp:HiddenField ID="hidDebit" runat="server" Value='<%# Eval("Debit")%>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Credit" ItemStyle-HorizontalAlign="Right">
                                <ItemTemplate>
                                    <asp:Label ID="lblCredit" runat="server" Text='<%# Eval("Credit")%>'></asp:Label>
                                    <asp:HiddenField ID="hidCredit" runat="server" Value='<%# Eval("Credit")%>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                </td>
            </tr>
        </table>       
    </div>
    
    </form>
</body>
</html>
 
     
     
     
   